package com.seadragon.apps.doctorcard.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.vividsolutions.jts.geom.Point;

@Entity
@Table(name = "request")
public class Request implements Serializable {
	private static final long serialVersionUID = 5672141192258714965L;

	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;

	@ManyToOne
	@JoinColumn(name="SENDER_ID")
	private Contact sender;
	@ManyToOne
	@JoinColumn(name="RECIPIENT_ID")
	private Contact recipient;

	@Column(name = "LOCATION_REQUESTED")
    @Type(type = "org.hibernate.spatial.GeometryType")
    private Point locationRequested;

	@Column(name = "LOCATION_RESPONDED")
    @Type(type = "org.hibernate.spatial.GeometryType")
    private Point locationResponded;

	@JsonSerialize(using = DateSerializer.class)
	@Column(name="DATE_REQUESTED")
	private Date dateRequested;

	@JsonSerialize(using = DateSerializer.class)
	@Column(name="DATE_RESPONDED")
	private Date dateResponded;

	@Column(name="MESSAGE")
	private String message;
	
	@Column(name="STATUS")
	private RequestStatus status;

	public Request(){}

	public Request(long requestId){
		this.id = requestId;
	}
	
	public Request(Contact sender, Contact recipient){
		this.sender = sender;
		this.recipient = recipient;
		this.status = RequestStatus.RequestSent;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public RequestStatus getStatus() {
		return status;
	}

	public Date getDateRequested() {
		return dateRequested;
	}

	public void setDateRequested(Date dateRequested) {
		this.dateRequested = dateRequested;
	}

	public Date getDateResponded() {
		return dateResponded;
	}

	public void setDateResponded(Date dateResponded) {
		this.dateResponded = dateResponded;
	}

	public void setStatus(RequestStatus status) {
		this.status = status;
	}

	public Contact getSender() {
		return sender;
	}

	public void setSender(Contact sender) {
		this.sender = sender;
	}

	public Contact getRecipient() {
		return recipient;
	}

	public void setRecipient(Contact recipient) {
		this.recipient = recipient;
	}

	public Point getLocationRequested() {
		return locationRequested;
	}

	public void setLocationRequested(Point locationRequested) {
		this.locationRequested = locationRequested;
	}

	public Point getLocationResponded() {
		return locationResponded;
	}

	public void setLocationResponded(Point locationResponded) {
		this.locationResponded = locationResponded;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

}
